package cn.learn;

import org.junit.Test;

/**
 * 二进制状态码
 *
 * @author huangyezhan
 * @version 1.0
 * @date 2020年08月04日0:39
 */
public class BinaryStatusCode {
    /**
     * 1    0001
     * 2    0010
     * 4    0100
     * 8    1000
     * 所有状态都满，为15
     */
    public final static Integer BIND_PHONE = 1;     //0001  用户绑定手机状态码
    public final static Integer BIND_EMAIL = 1 << 1;//0010  用户绑定邮箱
    public final static Integer BASIC_INFO = 1 << 2;//0100  用户是否填写基本资料
    public final static Integer REAL_AUTH  = 1 << 3;//1000  用户是否实名认证

    @Test
    public void test1() throws Exception {
        //1 手机
        Integer status = 1;
        System.out.println(BIND_EMAIL | status);

        System.out.println(BIND_PHONE | status);

        //总数为5
        Integer s2 = 5;
        System.out.println(s2 & BASIC_INFO);

        System.out.println(s2 ^ BASIC_INFO);


    }
}
